package com.heima.article.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.article.dtos.ArticleInfoDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ApArticleMapper extends BaseMapper<ApArticle> {

    /**
     * 查询文章列表
     *
     * @param dto
     * @param type 1：加载更多   2：加载最新
     * @return
     */
    public List<ApArticle> loadArticleList(@Param("dto") ArticleHomeDto dto, @Param("type") Short type);

    /**
     * 加载文章详情
     *
     * @param dto
     * @return
     */
    public ResponseResult loadArtilceInfo(ArticleInfoDto dto);

    //查询所有发布且未删除的文章

    @Select("SELECT aa.* FROM ap_article AS aa,ap_article_config AS aac WHERE aa.id=aac.article_id AND aac.is_down=0 AND aac.is_delete=0")
    List<ApArticle> findAllArticles();

}
